<template>
    <!--  <div class="layout">
          <Layout>

         </Layout>
          <Layout>

              <Layout :style="{padding: '0 24px 24px'}">
                  <Breadcrumb :style="{margin: '24px 0'}">
                      <BreadcrumbItem>Home</BreadcrumbItem>
                      <BreadcrumbItem>Components</BreadcrumbItem>
                      <BreadcrumbItem>Layout</BreadcrumbItem>
                  </Breadcrumb>
                  <Content :style="{padding: '24px', minHeight: '280px', background: '#fff'}">
                      Content
                  </Content>
              </Layout>
        </Layout>
      </div>-->
    <Layout>
        <Header style="font-size: 12px;position: relative;width: 100%"  >
            <Menu mode="horizontal" theme="dark" active-name="1">
                <div class="layout-logo">
                    <img style="width: 100px;height: 30px;" src="../assets/logo.png" alt="" class="logoImg">
                </div>
                <div class="homesystemNameCtl">
                    <span class="homesystemName">ERP采购管理系统</span>
                </div>
                <div class="layout-nav">
             <!--       <MenuItem name="1">
                        <Icon type="ios-navigate"></Icon>
                        Item 1
                    </MenuItem>
                    <MenuItem name="2">
                        <Icon type="ios-keypad"></Icon>
                        Item 2
                    </MenuItem>
                    <MenuItem name="3">
                        <Icon type="ios-analytics"></Icon>
                        Item 3
                    </MenuItem>-->
                    <MenuItem name="3" style="float: right">
                        <Icon type="ios-analytics"></Icon>
                        admin
                    </MenuItem>
                    <MenuItem name="4" style="float: right">
                        <Icon type="ios-power"@click="logOut"></Icon>
                        退出
                    </MenuItem>

                </div>
            </Menu>
        </Header>
        <Layout>
            <Sider hide-trigger style="background-color: #fff;max-height: 650px;overflow: auto">
                <Menu :active-name="LeftactiveIndex" theme="light" width="auto" :open-names="['1','2','3','4','5']"
                      @on-select="selectDispatchMenu">
                    <Submenu v-if="false" name="1">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            数据管理
                        </template>
                        <MenuItem name="/dataManagement/skuMg">sku管理</MenuItem>
                        <MenuItem name="/dataManagement/cangkuMg">仓库管理</MenuItem>
                    </Submenu>
                    <Submenu v-if="false"  name="2">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            采购管理
                        </template>
                        <MenuItem name="/ProcurementManagement/yaohuoMg">要货管理</MenuItem>
                        <MenuItem name="/ProcurementManagement/caigouMG">采购订单</MenuItem>
                        <MenuItem name="/ProcurementManagement/dianshouDanMg">点收单</MenuItem>
                        <MenuItem name="/ProcurementManagement/yanshouDanMg">验收单</MenuItem>
                        <MenuItem name="/ProcurementManagement/caigouTuiHuoDanMg">采购退货单</MenuItem>
                    </Submenu>
                    <Submenu  v-if="false"  name="3">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            库存管理
                        </template>
                        <MenuItem name="/kuCunManagement/initRuKuMg">初始入库</MenuItem>
                        <MenuItem name="/kuCunManagement/jieHuoDanMg">借货单</MenuItem>
                        <MenuItem name="/kuCunManagement/jieHuoFanHuanMg">借货返还</MenuItem>
                        <MenuItem name="/kuCunManagement/kucunTiaoZhenMg">库存调整</MenuItem>
                        <MenuItem name="3-2">仓库管理</MenuItem>
                        <MenuItem name="3-2">仓库管理</MenuItem>
                        <MenuItem name="3-2">仓库管理</MenuItem>
                    </Submenu>
                    <!--采购合同-->
                    <Submenu  name="4">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            采购合同
                        </template>
                        <MenuItem name="/cghtMg/add">采购合同-新增</MenuItem>
                        <MenuItem name="/cghtMg/weihu">采购合同-维护</MenuItem>
                        <MenuItem name="/cghtMg/htzxqkbb">合同执行情况报表</MenuItem>
                        <MenuItem name="/cghtMg/htjezxmxb">合同金额执行明细表</MenuItem>
                        <MenuItem name="/cghtMg/htjezxhzb">合同金额执行汇总表</MenuItem>
                    </Submenu>

                    <!--采购申请-->
                    <Submenu  name="5">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            采购申请
                        </template>
                        <MenuItem name="/cgsqdMg/add">采购申请单-新增</MenuItem>
                        <MenuItem name="/cgsqdMg/weihu">采购申请单-维护</MenuItem>
                    </Submenu>

                    <!--采购订单-->
                    <Submenu  name="6">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            采购订单
                        </template>
                        <MenuItem name="/cgddMg/add">采购订单-新增</MenuItem>
                        <MenuItem name="/cgddMg/weihu">采购订单-维护</MenuItem>
                        <MenuItem name="/cgddMg/cankan">采购订单-查看</MenuItem>
                        <MenuItem name="/cgddMg/cdddzxqkhzb">采购订单执行情况汇总表</MenuItem>
                        <MenuItem name="/cgddMg/cgddzxqkmxb">采购订单执行情况明细表</MenuItem>
                        <MenuItem name="/cgddMg/cgddqcgzbb">采购订单全程跟踪报表</MenuItem>
                    </Submenu>

                    <!--收料通知-->
                    <Submenu  name="7">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            收料通知
                        </template>
                        <MenuItem name="/slMg/add">收料通知/请检单 - 新增</MenuItem>
                        <MenuItem name="/slMg/smld">收料通知/请检单 - 扫描录单</MenuItem>
                        <MenuItem name="/slMg/weihu">收料通知/请检单 - 维护</MenuItem>
                    </Submenu>

                    <!--外购入库-->
                    <Submenu  name="8">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            外购入库
                        </template>
                        <MenuItem name="/wgrkMg/add">外购入库-新增</MenuItem>
                        <MenuItem name="/wgrkMg/smld">外购入库-扫描录单</MenuItem>
                        <MenuItem name="/wgrkMg/weihu">外购入库-维护</MenuItem>
                    </Submenu>

                    <!--采购发票-->
                    <Submenu  name="9">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            采购发票
                        </template>
                        <MenuItem name="/cgfpMg/add">采购发票 - 新增</MenuItem>
                        <MenuItem name="/cgfpMg/zysmld">采购发票（专用） - 扫描录单</MenuItem>
                        <MenuItem name="/cgfpMg/ptsmld">采购发票（普通） - 扫描录单</MenuItem>
                        <MenuItem name="/cgfpMg/weihu">采购发票  - 维护</MenuItem>
                        <MenuItem name="/cgfpMg/gjrz">采购发票  - 钩稽日志</MenuItem>
                        <MenuItem name="/cgfpMg/cgfpmxb">采购发票明细表</MenuItem>
                        <MenuItem name="/cgfpMg/gxwwjgfdzb">工序委外加工费对账表</MenuItem>
                    </Submenu>

                    <!--费用发票-->
                    <Submenu  name="10">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            费用发票
                        </template>
                        <MenuItem name="/fyfpMg/add">费用发票 - 新增</MenuItem>
                        <MenuItem name="/fyfpMg/weihu">费用发票 - 维护</MenuItem>
                        <MenuItem name="/fyfpMg/fyfphzb">费用发票汇总表</MenuItem>
                        <MenuItem name="/fyfpMg/fyfpmxb">费用发票明细表</MenuItem>
                    </Submenu>

                    <!--退料通知-->
                    <Submenu  name="11">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            退料通知
                        </template>
                        <MenuItem name="/tltzMg/add">退料通知 - 新增</MenuItem>
                        <MenuItem name="/tltzMg/weihu">退料通知 - 维护</MenuItem>
                    </Submenu>
                    <!--库存查询-->
                    <Submenu  name="12">
                        <template slot="title">
                            <Icon type="ios-analytics"></Icon>
                            库存查询
                        </template>
                        <MenuItem name="/kccxMg/jskccx">即时库存查询</MenuItem>
                        <MenuItem name="/kccxMg/kcztcx">库存状态查询</MenuItem>
                    </Submenu>
                </Menu>
            </Sider>
            <Content><router-view/></Content>
        </Layout>
        <Footer class="layout-footer-center"><span class="homeFooter">ERP采购管理系统 &copy;  版本:1.0.1</span></Footer>
    </Layout>
</template>
<script>
  import HelloWorld from '@/components/HelloWorld.vue';
  import newsApi from '@/api/news';
  import TEST from '@/api/test';

  export default {
    name: 'Home',
    components: {
      HelloWorld,
    },
    data() {
      return {
        LeftactiveIndex: '/ProcurementManagement/yaohuoMg',
      };
    },

    created() {
      // this.getData();
    },
    methods: {
      selectDispatchMenu(index) {
        this.LeftactiveIndex = index;
        this.$router.push(index);
      },
      handleSelectLeftMenu(index) {
        this.$router.push('index');
      },
      logOut(){
        this.$router.push('/')
      },
      //获取数据，无条件则获取全部数据
      getData() {
        console.log('用户信息');
        newsApi.findByPage({}).then(res => {
          // 返回数据
          console.log(res);
        }).catch(err => {
          // 异常情况
        });

      },
      getTest() {
        TEST.querySubscriber({
          fleetId: 67,
          all: 1,
        }).then(res => {
          // 返回数据
          console.log(res);
        }).catch(err => {
          // 异常情况
        });

      },
      handleReset() {
        this.$refs.form.resetFields();
        this.$emit('on-reset');
      },
      /*新增*/
      handleOpenCreate() {
        this.createData.noticeTitle = '';
        this.createData.content = '';
        this.createData.createBy = '';
        this.createData.noticeType = '';
        this.updateIndex = -1;
        this.showCreate = true;
      },

      //编辑
      handleEdit(mesId) {
        this.editMesId = mesId;
        newsApi.getMessageInfoById({
          mesId,
        }).then(res => {
          // 返回数据
          this.createData = res;
        }).catch(err => {
          // 异常情况
        });
        this.updateIndex = 11;
        this.showCreate = true;
      },
      // 新增数据
      handleCreate() {
        this.$refs.create.validate((valid) => {
          if (valid) {
            if (this.updateIndex < 0) {
              // 新建
              newsApi.addMessage({
                noticeTitle: this.createData.noticeTitle,
                content: this.createData.content,
                createBy: this.createData.createBy,
                noticeType: this.createData.noticeType,
              }).then(res => {
                // 返回数据
                this.$Message.success('创建成功');
                this.getData();
              }).catch(err => {
                // 异常情况
              });

            } else {
              // 修改
              newsApi.updateMessage({
                mesId: this.editMesId,
                noticeTitle: this.createData.noticeTitle,
                content: this.createData.content,
                createBy: this.createData.createBy,
                noticeType: this.createData.noticeType,
              }).then(res => {
                // 返回数据
                this.$Message.success('修改成功');
                this.getData();
              }).catch(err => {
                // 异常情况
              });

            }

            this.showCreate = false;
            this.creating = false;
            this.$nextTick(() => {
              this.creating = true;
            });
          } else {
            this.creating = false;
            this.$nextTick(() => {
              this.creating = true;
            });
          }
        });
      },

      // 详情
      showDetail(dxmbTywysbm) {
        const item = dxmbTywysbm;
        this.$router.push({
          path: '/employee/comuser/comuser-detail',
          name: 'comuser-detail',
          params: {
            item,
          },
        });
      },

      //删除
      handleDelete(mesId) {
        this.$Modal.confirm({
          title: '删除',
          content: '确定删除吗？',
          onOk: () => {
            newsApi.deleteById({
              mesId,
            }).then(res => {
              // 返回数据
              this.$Message.success('删除成功');
              this.getData();
            }).catch(err => {
              // 异常情况
              this.$Message.error('删除失败');
            });
          },
        });
      },
    },
  };
</script>
<style scoped>
    .layout{
        border: 1px solid #d7dde4;
        background: #f5f7f9;
        position: relative;
        border-radius: 4px;
        overflow: hidden;
    }
    .layout-logo{
        width: 100px;
        height: 30px;
        background: #5b6270;
        border-radius: 3px;
        float: left;
        position: relative;
        top: 15px;
        left: 20px;
    }
    .layout-nav{
        display: flex;
        position: absolute;
        right: 0;
    }
</style>
